package com.zqx.cor.controller;

import com.zqx.cor.abstracthandler.Approver;
import com.zqx.cor.request.PurchaseRequest;
import com.zqx.cor.specifichandler.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/cor")
public class CorController {


    @RequestMapping("/getPurchase")
    public String getPurchase(PurchaseRequest purchaseRequest){
        Approver zx = new Director("中翔");
        Approver sf = new Manager("三丰");
        Approver zqx = new VicePresident("谦行");
        Approver zyn = new President("张玉娜");
        Approver dsh = new Congress("董事会");
        //创建职责链
        zx.setSuccessor(sf);
        sf.setSuccessor(zqx);
        zqx.setSuccessor(zyn);
        zyn.setSuccessor(dsh);
        zx.processRequest(purchaseRequest);
        return "success";
    }
}
